//
//  PeiSongSetVController.m
//  Experss
//
//  Created by 嗯，大葱 on 17/8/14.
//  Copyright © 2017年 嗯，大葱. All rights reserved.
//

#import "PeiSongSetVController.h"
#import "SetTwoCell.h"
#import "LoginExperssController.h"
#import "AboutUSController.h"
@interface PeiSongSetVController ()
<UITableViewDelegate, UITableViewDataSource>
@end

@implementation PeiSongSetVController
-(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
    self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self configureNaBar];
    
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.separatorStyle = kSpNone;
    [_tableView registerNib:[UINib nibWithNibName:@"SetOneCell" bundle:nil] forCellReuseIdentifier:@"SetOneCell"];
    [_tableView registerNib:[UINib nibWithNibName:@"SetTwoCell" bundle:nil] forCellReuseIdentifier:@"SetTwoCell"];
    
}
- (void)configureNaBar {
    self.navigationItem.title = @"设置";
    //设置导航栏按钮的边距
    UIButton * rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    rightBtn.frame= CGRectMake(0, 0, 60, 30);
    [rightBtn setImage:[UIImage imageNamed:@"all_fanhui2"] forState:(UIControlStateNormal)];
    [rightBtn addTarget:self action:@selector(handleBackAxtion) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem *btn_left = [[UIBarButtonItem alloc] initWithCustomView:rightBtn];
    UIBarButtonItem *negativeSpacerleft = [[UIBarButtonItem alloc]   initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace   target:nil action:nil];
    /**
     width为负数时，相当于btn向右移动width数值个像素，由于按钮本身和  边界间距为5pix，所以width设为-5时，间距正好调整为0；width为正数 时，正好相反，相当于往左移动width数值个像素
     */
    negativeSpacerleft.width = -20;
    self.navigationItem.leftBarButtonItems = [NSArray arrayWithObjects:negativeSpacerleft, btn_left, nil];
    
    
    
}
- (void)handleBackAxtion {
    [self.navigationController popViewControllerAnimated:YES];
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 2;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 60;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 10;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    
    UIView *bg = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 10)];
    bg.backgroundColor = KShouYeBg;
    return bg;
    
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    NSArray *titA = @[@"检查更新",@"关于我们"];
    SetTwoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SetTwoCell"];
    cell.selectionStyle = kSeNone;
    cell.titleLB.text = titA[indexPath.row];
    return cell;
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
 
        if (indexPath.row == 1) {
            AboutUSController *ab = [[AboutUSController alloc] init];
            [self.navigationController pushViewController:ab animated:YES];
        
    }
}

- (void)handleBtnAction:(UIButton *)sender {
    sender.selected = !sender.selected;
}
//退出登录
- (IBAction)exitLoginAction:(UIButton *)sender {
    
    [SaveDataMethord cleanloginData];
//    LoginExperssController *login = [[LoginExperssController alloc] init];
//    self.view.window.rootViewController = login;
    
    LoginExperssController *login = [[LoginExperssController alloc] init];
    [self.navigationController pushViewController:login animated:YES];
}

@end

